import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import details from '../views/details.vue'
import cart from '../views/cart.vue'
Vue.use(VueRouter)

const routes = [{
		path: '/',
		name: 'Home',
		component: Home
	},
	{
		path: '/details',
		name: 'details',
		component: details
	},
	{
		path: '/cart',
		name: 'cart',
		component: cart
	},
	{
		path: '/main',
		name: 'main',
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/main.vue')
		}
	},
	{
		path: '/Search',
		name: 'Search',
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/Search.vue')
		}
	},
	{
		path: '/nav-fl',
		name: 'nav-fl',
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/nav-fl.vue')
		}
	},
	{
		path: '/login',
		name: 'login',
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/Login.vue')
		}
	},
	{
		path: '/SetUp',
		name: 'SetUp',
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/SetUp.vue')
		}
	},
	{
		path: '/main-GuanZhu',
		name: 'main-GuanZhu',
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/main-GuanZhu.vue')
		}
	},
	{
		path: '/Address',
		name: 'Address',
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/Address.vue')
		}
	},
	{
		path: '/settlement',
		name: 'settlement',
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/settlement.vue')
		}
	},
	{
		path: '/about',
		name: 'About',
		// route level code-splitting
		// this generates a separate chunk (about.[hash].js) for this route
		// which is lazy-loaded when the route is visited.
		component: function() {
			return import( /* webpackChunkName: "about" */ '../views/About.vue')
		}
	}
]

const router = new VueRouter({
	mode: 'history',
	base: process.env.BASE_URL,
	routes
})

// router.beforeEach((to, from, next) => {
// 	var login = localStorage.getItem('login')
// 	if (to.path == '/login' || login || to.path == '/cart' || to.path == '/' || to.path == '/details') {
// 		next()
// 	} else {
// 		alert('请先注册或登录')
// 		next('/login')
// 	}
// })
export default router
